const Proxy = require('../../proxy')
const webDataUtil = require('../../util/webDataUtil')
const BtbIndex = Proxy.BtbIndex

// 获取合约账户财务信息
module.exports = async function (params) {
  let query = {}
  query.code = params.code.toLocaleUpperCase()
  // 找出币
  let btbItem = await BtbIndex.findOne(query)
  if (!btbItem) {
    return
  }
  btbItem.symbol = `${btbItem.code}USDT`
  await webDataUtil.binance('futuresLeverage', {
    key: btbItem.symbol,
    quantity: params.leverage || 1
  })
  await BtbIndex.update({
    code: btbItem.code
  }, {
    leverage: params.leverage || 1
  })
  return {}
}
